Product
Introducing License Enforcement in Socket
Ensure open-source compliance with Socket’s License Enforcement Beta. Set up your License Policy and secure your software!
Move files and folders to the trash
Works on macOS, Linux, and Windows.
In contrast to fs.unlink
, del
, and rimraf
which permanently delete files, this only moves them to the trash, which is much safer and reversible.
$ npm install trash
const trash = require('trash');
trash(['*.png', '!rainbow.png']).then(() => {
console.log('done');
});
Returns a Promise
.
Type: Iterable<string>
Accepts paths and glob patterns.
Type: Object
Type: boolean
Default: true
Enable globbing when matching file paths.
To install the trash
command, run:
$ npm install --global trash-cli
On macOS, macos-trash
is used.
On Linux, the XDG spec is followed.
On Windows, recycle-bin
is used.
mv
Not really. The mv
command isn't cross-platform and moving to trash is not just about moving the file to a "trash" directory. On all OSes you'll run into file conflicts. The user won't easily be able to restore the file. It won't work on an external drive. The trash directory location varies between Windows versions. For Linux, there's a whole spec you need to follow. On macOS, you'll lose the Put back feature.
MIT © Sindre Sorhus
FAQs
Move files and folders to the trash
We found that trash demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Ensure open-source compliance with Socket’s License Enforcement Beta. Set up your License Policy and secure your software!
Product
We're launching a new set of license analysis and compliance features for analyzing, managing, and complying with licenses across a range of supported languages and ecosystems.
Product
We're excited to introduce Socket Optimize, a powerful CLI command to secure open source dependencies with tested, optimized package overrides.